home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI2000 / TI2000.ASC next >
Text File  |  1993-04-08  |  2KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Pascal                                NUMBER  :  2000
  9.   VERSION  :  7.0
  10.        OS  :  WIN
  11.      DATE  :  April 8, 1993                            PAGE  :  1/2
  12.  
  13.     TITLE  :  Pause your code while you execute another app
  14.  
  15.  
  16.  
  17.  
  18.   Code which allows you to launch another Windows program and then
  19.   wait until it ends before executing any more of your code.
  20.  
  21.      1.  {
  22.          Use this code to launch a second program from inside a
  23.          Turbo
  24.          Pascal for Windows program. It accepts the same parameters
  25.          as
  26.          WinExec, but will loop continuously until the launched
  27.          program
  28.          has terminated. This code exists because it is sometimes
  29.          necessary to launch a second program without executing any
  30.          more
  31.          code in your program. If you did not take this approach,
  32.          then
  33.          both programs would be executing simultaneously via
  34.          Windows
  35.          multitasking abilities. }
  36.  
  37.      2.  function WinExecAndWait(Path : Pchar; Visibility : word) :
  38.          word;
  39.          var
  40.          InstanceID : THandle;
  41.          Msg : TMSg;
  42.          begin
  43.          InstanceID := WinExec(Path,Visibility);
  44.          if InstanceID < 32 then { a value less than 32 indicates
  45.          an
  46.                    Exec error }
  47.          WinExecAndWait := InstanceID
  48.          else
  49.          repeat
  50.          while PeekMessage(Msg,0,0,0,PM_REMOVE) do
  51.          begin
  52.          if Msg.Message = WM_QUIT then
  53.            halt(Msg.wParam);
  54.          TranslateMessage(Msg);
  55.          DispatchMessage(Msg);
  56.          end;
  57.          until GetModuleUsage(InstanceID) = 0;
  58.          end;
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Pascal                                NUMBER  :  2000
  75.   VERSION  :  7.0
  76.        OS  :  WIN
  77.      DATE  :  April 8, 1993                            PAGE  :  2/2
  78.  
  79.     TITLE  :  Pause your code while you execute another app
  80.  
  81.  
  82.  
  83.  
  84.   DISCLAIMER: You have the right to use this technical information
  85.   subject to the terms of the No-Nonsense License Statement that
  86.   you received with the Borland product to which this information
  87.   pertains.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.